package cn.cool.controller;


import cn.cool.entity.Article;
import cn.cool.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LiuH
 * @since 2021-01-23
 */
@RestController
@RequestMapping("/article")
@Api(tags = "文章接口")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @PostMapping("/addArticle")
    @ApiOperation(value = "用户发表文章")
    public Object addArticle(HttpServletRequest request, Article article){
        Object result = articleService.addArticle(request, article);
        return result;
    }

    @GetMapping("/articleInfo")
    @ApiOperation(value = "查看具体文章")
    public Object articleInfo(HttpServletRequest request,Integer artId){
        Object info = articleService.getArticleInfo(request,artId);
        return info;
    }


}

